<template>
  <h4>{{ person }}</h4>
  <h1>姓名：{{ name }}</h1>
  <h1>年龄：{{ age }}</h1>
  <h1>薪资：{{ job.j1.salary }}w</h1>
  <button @click="name += '~'">增加波浪线</button>
  <button @click="age++">增长年龄</button>
  <button @click="job.j1.salary++">加薪</button>
</template>

<script>
import { reactive, toRef, toRefs } from "vue";

export default {
  name: "Demo",
  setup() {
    const person = reactive({
      name: "李文泰",
      age: 20,
      job: {
        j1: {
          salary: "20",
        },
      },
    });

    // const name = toRef(person, "name");
    // console.log("@@@", name.value);

    const x = toRefs(person);
    console.log(x);

    //返回对象
    return {
      person,
      // name: toRef(person, "name"),
      // age: toRef(person, "age"),
      // salary: toRef(person.job.j1, "salary"),
      ...toRefs(person),
    };
  },
};
</script>

<style>
</style>
